﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NFinal
{
    /// <summary>
    /// Action接口类
    /// </summary>
    public interface IAction
    {
        /// <summary>
        /// 请求是否来自移动端
        /// </summary>
        bool isMobile { get; }
        /// <summary>
        /// 请求返回的页面类型
        /// </summary>
        string ContentType { get; set; }
        /// <summary>
        /// 请求时的流
        /// </summary>
        System.IO.Stream InputStream { get; }
        /// <summary>
        /// 取得请求头
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        string GetRequestHeader(string key);
        /// <summary>
        /// 设置请求头
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        void SetResponseHeader(string key,string value);
        /// <summary>
        /// 设置请求头
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        void SetResponseHeader(string key, string[] value);
        /// <summary>
        /// 设置状态码
        /// </summary>
        /// <param name="statusCode"></param>
        void SetResponseStatusCode(int statusCode);
        /// <summary>
        /// 模板渲染前函数，用于子类重写
        /// </summary>
        void Before();
        /// <summary>
        /// 模板渲染后函数，用于子类重写
        /// </summary>
        void After();
        /// <summary>
        /// 关闭资源
        /// </summary>
        void Close();
        /// <summary>
        /// 输出文本并输出<br/>
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="obj">对象</param>
        void WriteLine<T>(T obj);
        /// <summary>
        /// 输出文本对象
        /// </summary>
        /// <param name="obj">字符串</param>
        void Write(string obj);
        /// <summary>
        /// 把对象转为字符串并输出
        /// </summary>
        /// <typeparam name="T">对象类型</typeparam>
        /// <param name="obj">对象</param>
        void Write<T>(T obj);
        /// <summary>
        /// 输出字节流，用于输出二进制流，如图象，文件等。
        /// </summary>
        /// <param name="buffer"></param>
        void Write(byte[] buffer);
        /// <summary>
        /// 返回json{code:1,msg:"",result:[json字符串]}
        /// </summary>
        /// <param name="json">json字符串</param>
        void AjaxReturn(string json);
        /// <summary>
        /// 返回json{code:1,msg:"",result:[json字符串]}
        /// </summary>
        void AjaxReturn();
        /// <summary>
        /// 渲染模板
        /// </summary>
        /// <param name="tplPath">模板相对路径</param>
        void View(string tplPath);
        /// <summary>
        /// 渲染模板
        /// </summary>
        /// <param name="name">文件夹名</param>
        /// <param name="tplPath">模板文件夹名</param>
        void View(string name, string tplPath);
        /// <summary>
        /// 页面重定向
        /// </summary>
        /// <param name="url">重定向url</param>
        void Redirect(string url);
    }
}
